package xyz.robinbingo.rbtask.mapper.base;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.io.Serializable;
import java.util.Collection;

/**
 * CustomBaseMapper
 *
 * @author Robin
 * @date 2021/7/17 19:08
 **/
@Mapper
public interface CustomBaseMapper<T> extends BaseMapper<T> {

    /**
     * 逻辑删除并更新必要字段
     *
     * @param entity entity
     * @return int
     * @author Robin
     * @date 2021/7/17 19:08
     **/
    int deleteByIdWithFill(T entity);

    /**
     * 根据条件逻辑删除，并更新必要字段
     *
     * @param entity  entity
     * @param wrapper wrapper
     * @return int
     * @author Robin
     * @date 2021/8/31 19:36
     **/
    int deleteByWrapperWithFill(@Param(Constants.ENTITY) T entity, @Param(Constants.WRAPPER) Wrapper<T> wrapper);

    /**
     * 根据idList逻辑删除，并更新必要字段
     *
     * @param entity entity
     * @param idList idList
     * @return int
     * @author Robin
     * @date 2021/8/31 19:36
     **/
    int deleteByIdsWithFill(@Param(Constants.ENTITY) T entity, @Param(Constants.COLLECTION) Collection<? extends Serializable> idList);
}
